package book

import (
     "wskyygyso/api/pkg/database"
)

func Get(idstr string) (book Book) {
    database.DB.Where("id", idstr).First(&book)
    return
}

func GetBy(field, value string) (book Book) {
    database.DB.Where("? = ?", field, value).First(&book)
    return
}

func All() (Books []Book) {
    database.DB.Find(&Books)
    return
}

func IsExist(field, value string) bool {
    var count int64
    database.DB.Model(Book{}).Where(" = ?", field, value).Count(&count)
    return count > 0
}